package com.zqx.spmab.service;

import com.github.pagehelper.Page;
import com.zqx.spmab.commons.FileUploadBean;
import com.zqx.spmab.pojo.domain.Attachment;
import com.zqx.spmab.pojo.form.AttachmentForm;
import com.zqx.spmab.pojo.query.AttachmentQuery;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.util.List;

/**
 *
 * Created by Zqx on 2018/4/24.
 */
public interface AttachmentService {

    /**
     * 上传文件
     */
    String uploadFile(MultipartFile uploadItem,final AttachmentForm form) throws Exception;

    /**
     * 上传文件--存放不改变文件名称
     */
    String uploadFileOnOldName(FileUploadBean uploadItem,AttachmentForm form) throws Exception;

    /**
     * 下载文件
     */
    void download(String id, HttpServletResponse response) throws FileNotFoundException;

    /**
     * 查询 Attachment
     */
    List<Attachment> find(final AttachmentQuery query);

    /**
     * 分页查询 Attachment
     */
    Page<Attachment> findByPage(final AttachmentQuery query);

    /**
     * 通过id得到一个 Attachment
     */
    Attachment get(final String id);

    /**
     * 新增 Attachment
     */
    void add(final AttachmentForm form);

    /**
     * 修改 Attachment
     */
    int update(final AttachmentForm form);

    /**
     * 删除一个 Attachment
     */
    int delete(final String id);

    /**
     * 修改是否可用
     */
    int changeEnabled(final String id, final Integer enabled);
}
